package com.smile.service.impl;

import com.smile.model.dto.request.SpeakerAudioPlayStartRequestDTO;
import com.smile.model.dto.request.SpeakerPlayModeSetRequestDTO;
import com.smile.model.dto.request.SpeakerPlayVolumeSetRequestDTO;
import com.smile.model.dto.request.SpeakerTtsPlayStartRequestDTO;
import com.smile.service.SpeakerService;
import com.smile.service.entity.services.SpeakerPlayVolumeSetData;
import com.smile.service.task.SpeakServicesExecutor;
import lombok.Data;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.stereotype.Service;

@Service
public class SpeakerServiceImpl implements SpeakerService {


    @Override
    public void speakerPlayVolumeSet(SpeakerPlayVolumeSetRequestDTO speakerPlayVolumeSetRequestDTO) throws MqttException {
        SpeakServicesExecutor.create()
                .speakerPlayVolumeSet(speakerPlayVolumeSetRequestDTO.getPlayVolume())
                .gateway(speakerPlayVolumeSetRequestDTO.getGateway())
                .execute();
    }

    @Override
    public void speakerPlayModeSet(SpeakerPlayModeSetRequestDTO speakerPlayModeSetRequestDTO) throws MqttException {
        SpeakServicesExecutor.create()
                .speakerPlayModeSet(speakerPlayModeSetRequestDTO.getPlayMode())
                .gateway(speakerPlayModeSetRequestDTO.getGateway())
                .execute();
    }

    @Override
    public void speakerTtsPlayStart(SpeakerTtsPlayStartRequestDTO speakerTtsPlayStartRequestDTO) throws MqttException {
        SpeakServicesExecutor.create().
                speakerTtsPlayStart(speakerTtsPlayStartRequestDTO.getName(),
                        speakerTtsPlayStartRequestDTO.getText(),
                        speakerTtsPlayStartRequestDTO.getMd5())
                .gateway(speakerTtsPlayStartRequestDTO.getGateway())
                .execute();
    }

    @Override
    public void speakerAudioPlayStartRequest(SpeakerAudioPlayStartRequestDTO speakerAudioPlayStartRequestDTO) throws MqttException {
        SpeakServicesExecutor.create()
                // name url md5
                .speakerAudioPlayStart(speakerAudioPlayStartRequestDTO.getName(), speakerAudioPlayStartRequestDTO.getUrl(),
                        speakerAudioPlayStartRequestDTO.getMd5())
                .gateway(speakerAudioPlayStartRequestDTO.getGateway())
                .execute();
    }


}
